import java.io.*;
/**
 * Created by zyl on 17-6-1.
 */
public class MyCP {
    public static void tenTotwo(String in,String out) throws IOException{
        try(FileInputStream file1 = new FileInputStream(in);FileOutputStream file2 = new FileOutputStream(out)){
            byte[] data = new byte[1024];
            byte[] x = new byte[1];
            int length = -1,i=0,sum=0;
            length = file1.read(data);
            //System.out.println(length);
            while(i<length-1){
                //灏嗚鍏ョ殑ascii杞崲涓虹湡鍊煎苟姹傚拰
                sum=sum*10 + data[i]-48;
                i++;
            }
            //System.out.println(sum);
            //璋冪敤Integer.toBinaryString>鏂规硶灏唖um鐨勪簩杩涘埗琛ㄧず瀛樺叆瀛楃涓??
            //String str = Integer.toBinaryString(sum);
            //System.out.println(str);

            file2.write(sum);
        }
    }
    public static void twoToten(String in,String out) throws IOException{
        try(FileInputStream file1 = new FileInputStream(in);FileOutputStream file2 = new FileOutputStream(out)){
            byte[] data = new byte[1024];
            int length = -1,i=0,j=0;
            length = file1.read(data);
            while(i<length-1) {
                //System.out.printf(data[i]);
                String str = Integer.toString(0xff+data[i]+1,10);
                //System.out.println(str);
                char[] mytxt = str.toCharArray();
                //System.out.println(mytxt);
                for(j=0;j<str.length();j++)
                {
                    file2.write(mytxt[j]);
                }
                i++;
            }
        }
    }
    public static void main(String[] args) throws IOException{
        if(args[0].equals("-tx")){
            tenTotwo(args[1],args[2]);
        }
        else if(args[0].equals("-xt")) {
            twoToten(args[1],args[2]);
        }
        MyCP.tenTotwo("In1.txt","In2.bin");
        MyCP.twoToten("Out1.bin","Out2.txt");
    }

}

